package cn.zurish.cloud.security.handler.impl1;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.PermissionEvaluator;
import org.springframework.security.core.Authentication;

import java.io.Serializable;

@RequiredArgsConstructor
public class AbacPermissionEvaluator implements PermissionEvaluator {

    private final AbacDecisionEngine abacEngine;
    @Override
    public boolean hasPermission(Authentication auth, Object targetDomainObject, Object permission) {
        return abacEngine.check(auth, (String)permission);
    }

    @Override
    public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType, Object permission) {
        // 本示例仅实现 hasPermission(Authentication, Object, Object)
        return false;
    }
}
